package com.wd.common.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.gyf.immersionbar.ImmersionBar

/**
 * 作者：马海钊
 * 时间：2024/5/26 19:58
 * 功能：
 */
abstract class BaseFragment<VB : ViewBinding> : Fragment() {
    private lateinit var _binding: VB
    protected val binding get() = _binding


    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        _binding = getViewBinding(inflater, container)
        return _binding.root
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        initData()
        ImmersionBar.with(this)
            .statusBarAlpha(0.4f)  //状态栏透明度，不写默认0.0f
            .init()
    }

    abstract fun initData()

    abstract fun getViewBinding(inflater: LayoutInflater, container: ViewGroup?): VB
}